/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BusinessLogic;

import DataAccess.SalesMenFunction_DA;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.table.TableModel;

/**
 *
 * @author MrToan
 */
public class SalesMenFunction_BL {

    private String CusID;
    SalesMenFunction_DA function_DA=new SalesMenFunction_DA();
    public TableModel UserTable()
    {
        TableModel TB=function_DA.getUserTableValue();
        return TB;
    }

    
    public TableModel ItemTable()
    {
        TableModel TB=function_DA.getItemTableValue();
        return TB;
    }

    
    public Vector getCategory()
    {
        Vector Cate=function_DA.getCate();
        return Cate;
    }

    public Vector getCateChanged(String cate) {
        Vector Cate=function_DA.getCate();
        return Cate;
    }

    public TableModel BillTable(String Date)
    {
        TableModel TB=function_DA.getBillTableValue(Date);
        return TB;
    }
    public TableModel ItemTableChanged(String cateChanged) {
        TableModel TB=function_DA.getItemChanged(cateChanged);
        return TB;
    }

    public int AddBill(String CID,String Date,String UID,String Payment,float Discount,int Status,float Total)
    {
        int InsertSuccess=0;
        InsertSuccess=function_DA.AddBill(CID, Date, UID, Payment, Discount, Status, Total);
        return InsertSuccess;
    }

    public int getBillID()
    {
        int BID=function_DA.getBID();
        return BID;
    }

    public TableModel getItembyName(String itemName,String cateName) {
        TableModel tb = new SalesMenFunction_DA().getItemtoTable(itemName,cateName);
        return tb;
    }

    public String addNewCustomer(String custName, String email, String address, String tel, boolean gender, String city, String country, int status, float purchar) {
        int respond = new SalesMenFunction_DA().addNewCustomer_DA(custName,email,address,tel,gender,city,country,status,purchar);
        String message=null;
        if(respond!=0)
        {
            message = "Insert New Customer Successful!";
        }else{
            message = "Insert new Customer Fail";
        }
        return message;
    }

    public int getCustID() {
        int CID=function_DA.getCID();
        System.out.println(""+CID);
        return CID;
    }

    public String deleteCustomer(int custID) {
        int respond = new SalesMenFunction_DA().deleteCustomer_DA(custID);
        String message=null;
        if(respond!=0)
        {
            message="Delete Customer Successful !";
        }else{
            message="Please Choose Customer!";
        }
        return message;
    }

    public String updateCustomer(int custID,String custName, String email, String address, String tel, boolean gender, String city, String country, int status, float purchar) {
        int respond = new SalesMenFunction_DA().updateCustomer_DA(custID,custName,email,address,tel,gender,city,country,status,purchar);
        String message = null;
         if(respond!=0)
        {
            message="Update Customer Successful !";
        }else{
            message="Please Choose Customer!";
        }
        return message;
    }

    public Item getItemInfor(String itemID){
        Item it = new SalesMenFunction_DA().getItemInfor_DA(itemID);
        return it;
    }

    public String addNewBill(Bill bill,ArrayList<BillDetails> billDetails) {
        int respond = new SalesMenFunction_DA().addNewBill_DA(bill,billDetails);
        String message=null;
        if(respond!=0)
        {
            message="Create Bill Successful!";
        }else{
            message="Create Bill Fail!";
        }
        return message;
    }

    public TableModel tableBillList() {
        TableModel tbBillList = new SalesMenFunction_DA().tableBillList_DA();
        return tbBillList;
    }

    public TableModel getBillDetails(int B_ID) {
        TableModel tbBillDetails = new SalesMenFunction_DA().getBillDetails_DA(B_ID);
        return tbBillDetails;
    }

    public String cancelBill(int billID) {
        int respond = new SalesMenFunction_DA().cancelBill_DA(billID);
        String message = null;
        if(respond!=0)
        {
            message="Cancel Bill Successful!";
        }else{
            message ="Cancel Bill Fail!";
        }
        return message;
    }

    public int CountCate()
    {
        int count=function_DA.CountCategory();
        return count;
    }
    public int CountItem()
    {
        int Count=function_DA.getTotalItems();
        return Count;
    }

    public int ViewItemAvailable()
    {
        int Item=function_DA.ViewItemAvailable();
        return Item;
    }

    public TableModel ViewItem() {
        TableModel TB=function_DA.ViewItem();
        return TB;
    }

    public TableModel getItemByDate(String DateTime,int index) {
        TableModel tb=function_DA.ViewItemByDate(DateTime,index);
        return tb;
    }
}
